﻿namespace ManagerClinic.HoSoKhamBenh
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using DevExpress.XtraEditors;
    using ManagerClinic.Core.Common;
    using ManagerClinic.Core.Business;

    public partial class frmDanhSachHoSoKhamBenh : DevExpress.XtraEditors.XtraForm
    {
        HoSoKhamBenhNgoaiTruBusiness hoSoKhamBenhNgoaiTruBusiness = new HoSoKhamBenhNgoaiTruBusiness();
        Form parentForm = null;

        public frmDanhSachHoSoKhamBenh(Form frm)
        {
            InitializeComponent();
            dtCurrentDate.EditValue = DateTime.Now;
            parentForm = frm;
        }

        private void frmDanhSachHoSoKhamBenh_Load(object sender, EventArgs e)
        {
            LoadData();
        }

        void LoadData()
        {
            var lstHoSoKhamBenhEntity = hoSoKhamBenhNgoaiTruBusiness.GetHoSoKhamBenhNgoaiTruList(Convert.ToDateTime(dtCurrentDate.EditValue));
            grdDanhSachHoSoKhamBenh.DataSource = lstHoSoKhamBenhEntity;
        }

        private void btnDong_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void dtCurrentDate_EditValueChanged(object sender, EventArgs e)
        {
            LoadData();
        }

        private void grdDanhSachHoSoKhamBenh_DoubleClick(object sender, EventArgs e)
        {
            if (gvDanhSachBenhNhanKhamBenh.RowCount <= 0) return;
            var hoSoKhamBenhEntity = (HoSoKhamBenhNgoaiTruEntity)gvDanhSachBenhNhanKhamBenh.GetFocusedRow();
            var frm = new frmHoSoKhamBenh(hoSoKhamBenhEntity);
            frm.MdiParent = parentForm;
            frm.Show();
        }
    }
}